package com.lanou.beautifulwardrobe.Home.Adapter;

import android.graphics.Bitmap;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.Response;
import com.lanou.beautifulwardrobe.R;
import com.lanou.beautifulwardrobe.contants.VolleySingleton;
import com.lanou.beautifulwardrobe.entify.DetailMobileDesc;
import com.lanou.beautifulwardrobe.entify.DetailPropsName;

import java.util.List;

/**
 * Created by dllo on 15/11/3.
 */
public class ProductParameterAdapter extends RecyclerView.Adapter<ProductParameterAdapter.ParameterViewHolder> {
    private static ProductParameterAdapter adapter;

    public static ProductParameterAdapter getInstance() {
        if (adapter == null) {
            adapter = new ProductParameterAdapter();
        }
        return adapter;
    }

    private List<DetailPropsName> datas;
    private VolleySingleton volleySingleton=VolleySingleton.getInstance();

    public void addData(List<DetailPropsName> datas) {
        this.datas = datas;
        notifyDataSetChanged();
    }

    @Override
    public ParameterViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.home_product_parameter_item, null);
        return new ParameterViewHolder(view);
    }

    @Override
    public void onBindViewHolder(final ParameterViewHolder holder, int position) {
        if(datas != null && datas.size() >0 ){
            DetailPropsName propsName=datas.get(position);
            holder.parapname.setText(propsName.getPname());
            holder.paravname.setText(propsName.getVname());
        }

    }

    @Override
    public int getItemCount() {
        return datas != null && datas.size() > 0 ? datas.size() : 0;
    }

    class ParameterViewHolder extends RecyclerView.ViewHolder {
        private TextView parapname,paravname;

        public ParameterViewHolder(View itemView) {
            super(itemView);
            parapname= (TextView) itemView.findViewById(R.id.parapname);
            paravname= (TextView) itemView.findViewById(R.id.paravname);
        }
    }
}
